package com.qf.xml.service.impl;

import com.qf.xml.dao.UserDao;
import com.qf.xml.service.UserService;

public class UserServiceImpl  implements UserService {

    //userservice的业务需要通过dao来完成，这里需要有一个dao的引用
    //这个在service代码中的dao引用我们称之为依赖引用，简称依赖
    private UserDao userDao;

    private String name;

    public void setName(String name) {
        this.name = name;
    }

    //通过构造方法给依赖引用赋值 -- 依赖注入（DI）
    public UserServiceImpl(UserDao userDao) {
        this.userDao = userDao;
    }

    public UserServiceImpl(UserDao userDao,int a) {
        this.userDao = userDao;
    }



    //通过setter方法给依赖引用赋值 -- 依赖注入(DI)
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public UserServiceImpl() {
        System.out.println("init~~~");
    }

    public void initM(){
        System.out.println("init method 执行了~~");
    }

    public void desM(){
        System.out.println("destroy method 执行了~~");
    }

    @Override
    public void findAll() {
        System.out.println("service findAll run ~~");

        userDao.findAll();
    }
}
